package acm.蓝桥12;

import java.util.Scanner;

/**
 * 暴力：
 *
// */
public class 组成三角形 {

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        long t = sc.nextLong();
        while (t-- > 0) {
            long n = sc.nextLong();
            long fun = fun(n);
            System.out.println(fun);
        }
    }
    public static int fun(long n){
        int res=0;
        for (long i = 1; i <= n; i++) {
            for (long j = i+1; j <= n; j++) {
                for (long k = j+1; k <= n; k++) {
                    if (check1(i,j,k)&&check2(i,j,k)){
                        res+=6;
                    }
                }
            }
        }
        return res;
    }
    public static boolean check1(long a,long b,long c){
        return (a^b^c)==0;
    }
    public static boolean check2(long a,long b,long c){
        return (a+b>c)&&(a+c>b)&&(b+c>a);
    }
}
